<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link href="cpip.css" rel="stylesheet" type="text/css" />
    <title>File: /Users/paulross/dev/Python-3.6.2/Include/pymath.h</title>
  </head>
  <body>
    <h1>File: /Users/paulross/dev/Python-3.6.2/Include/pymath.h</h1>
    <p>Green shading in the line number column
means the source is part of the translation unit, red means it is conditionally excluded.
Highlighted line numbers link to the translation unit page. Highlighted macros link to
the macro page.</p>
    <pre><a name="1" /><span class="True">       1:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfUFlNQVRIX0hfMA__"><span class="b">Py_PYMATH_H</span></a>
<a name="2" /><span class="True">       2:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfUFlNQVRIX0hfMA__"><span class="b">Py_PYMATH_H</span></a>
<a name="3" /><span class="True">       3:</span> 
<a name="4" /><span class="True">       4:</span> <span class="f">#</span><span class="n">include</span> <span class="e">&quot;pyconfig.h&quot;</span> <span class="k">/* include for defines */</span>
<a name="5" /><span class="True">       5:</span> 
<a name="6" /><span class="True">       6:</span> <span class="k">/**************************************************************************</span>
<a name="7" /><span class="True">       7:</span> <span class="k">Symbols and macros to supply platform-independent interfaces to mathematical</span>
<a name="8" /><span class="True">       8:</span> <span class="k">functions and constants</span>
<a name="9" /><span class="True">       9:</span> <span class="k">**************************************************************************/</span>
<a name="10" /><span class="True">      10:</span> 
<a name="11" /><span class="True">      11:</span> <span class="k">/* Python provides implementations for copysign, round and hypot in</span>
<a name="12" /><span class="True">      12:</span> <span class="k"> * Python/pymath.c just in case your math library doesn&apos;t provide the</span>
<a name="13" /><span class="True">      13:</span> <span class="k"> * functions.</span>
<a name="14" /><span class="True">      14:</span> <span class="k"> *</span>
<a name="15" /><span class="True">      15:</span> <span class="k"> *Note: PC/pyconfig.h defines copysign as _copysign</span>
<a name="16" /><span class="True">      16:</span> <span class="k"> */</span>
<a name="17" /><span class="False">      17:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_ref.html#_SEFWRV9DT1BZU0lHTl8w"><span class="b">HAVE_COPYSIGN</span></a>
<a name="18" /><span class="False">      18:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">copysign</span><span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="19" /><span class="True">      19:</span> <span class="f">#</span><span class="n">endif</span>
<a name="20" /><span class="True">      20:</span> 
<a name="21" /><span class="False">      21:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_ref.html#_SEFWRV9ST1VORF8w"><span class="b">HAVE_ROUND</span></a>
<a name="22" /><span class="False">      22:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">round</span><span class="f">(</span><span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="23" /><span class="True">      23:</span> <span class="f">#</span><span class="n">endif</span>
<a name="24" /><span class="True">      24:</span> 
<a name="25" /><span class="False">      25:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_ref.html#_SEFWRV9IWVBPVF8w"><span class="b">HAVE_HYPOT</span></a>
<a name="26" /><span class="False">      26:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">hypot</span><span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="27" /><span class="True">      27:</span> <span class="f">#</span><span class="n">endif</span>
<a name="28" /><span class="True">      28:</span> 
<a name="29" /><span class="True">      29:</span> <span class="k">/* extra declarations */</span>
<a name="30" /><span class="True">      30:</span> <span class="f">#</span><span class="n">ifndef</span> <span class="b">_MSC_VER</span>
<a name="31" /><span class="True">      31:</span> <span class="f">#</span><span class="n">ifndef</span> <span class="b">__STDC__</span>
<a name="32" /><span class="True">      32:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">fmod</span> <span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="33" /><span class="True">      33:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">frexp</span> <span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">int</span> <span class="f">*</span><span class="f">)</span><span class="f">;</span>
<a name="34" /><span class="True">      34:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">ldexp</span> <span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">int</span><span class="f">)</span><span class="f">;</span>
<a name="35" /><span class="True">      35:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">modf</span> <span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">double</span> <span class="f">*</span><span class="f">)</span><span class="f">;</span>
<a name="36" /><span class="True">      36:</span> <span class="m">extern</span> <span class="m">double</span> <span class="b">pow</span><span class="f">(</span><span class="m">double</span><span class="f">,</span> <span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="37" /><span class="True">      37:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* __STDC__ */</span>
<a name="38" /><span class="True">      38:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* _MSC_VER */</span>
<a name="39" /><span class="True">      39:</span> 
<a name="40" /><span class="True">      40:</span> <span class="k">/* High precision definition of pi and e (Euler)</span>
<a name="41" /><span class="True">      41:</span> <span class="k"> * The values are taken from libc6&apos;s math.h.</span>
<a name="42" /><span class="True">      42:</span> <span class="k"> */</span>
<a name="43" /><span class="True">      43:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfTUFUSF9QSWxfMA__"><span class="b">Py_MATH_PIl</span></a>
<a name="44" /><span class="True">      44:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfTUFUSF9QSWxfMA__"><span class="b">Py_MATH_PIl</span></a> <span class="c">3.1415926535897932384626433832795029L</span>
<a name="45" /><span class="True">      45:</span> <span class="f">#</span><span class="n">endif</span>
<a name="46" /><span class="True">      46:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfTUFUSF9QSV8w"><span class="b">Py_MATH_PI</span></a>
<a name="47" /><span class="True">      47:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfTUFUSF9QSV8w"><span class="b">Py_MATH_PI</span></a> <span class="c">3.14159265358979323846</span>
<a name="48" /><span class="True">      48:</span> <span class="f">#</span><span class="n">endif</span>
<a name="49" /><span class="True">      49:</span> 
<a name="50" /><span class="True">      50:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfTUFUSF9FbF8w"><span class="b">Py_MATH_El</span></a>
<a name="51" /><span class="True">      51:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfTUFUSF9FbF8w"><span class="b">Py_MATH_El</span></a> <span class="c">2.7182818284590452353602874713526625L</span>
<a name="52" /><span class="True">      52:</span> <span class="f">#</span><span class="n">endif</span>
<a name="53" /><span class="True">      53:</span> 
<a name="54" /><span class="True">      54:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfTUFUSF9FXzA_"><span class="b">Py_MATH_E</span></a>
<a name="55" /><span class="True">      55:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfTUFUSF9FXzA_"><span class="b">Py_MATH_E</span></a> <span class="c">2.7182818284590452354</span>
<a name="56" /><span class="True">      56:</span> <span class="f">#</span><span class="n">endif</span>
<a name="57" /><span class="True">      57:</span> 
<a name="58" /><span class="True">      58:</span> <span class="k">/* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */</span>
<a name="59" /><span class="True">      59:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfTUFUSF9UQVVfMA__"><span class="b">Py_MATH_TAU</span></a>
<a name="60" /><span class="True">      60:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfTUFUSF9UQVVfMA__"><span class="b">Py_MATH_TAU</span></a> <span class="c">6.2831853071795864769252867665590057683943L</span>
<a name="61" /><span class="True">      61:</span> <span class="f">#</span><span class="n">endif</span>
<a name="62" /><span class="True">      62:</span> 
<a name="63" /><span class="True">      63:</span> 
<a name="64" /><span class="True">      64:</span> <span class="k">/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU</span>
<a name="65" /><span class="True">      65:</span> <span class="k">   register and into a 64-bit memory location, rounding from extended</span>
<a name="66" /><span class="True">      66:</span> <span class="k">   precision to double precision in the process.  On other platforms it does</span>
<a name="67" /><span class="True">      67:</span> <span class="k">   nothing. */</span>
<a name="68" /><span class="True">      68:</span> 
<a name="69" /><span class="True">      69:</span> <span class="k">/* we take double rounding as evidence of x87 usage */</span>
<a name="70" /><span class="True">      70:</span> <span class="f">#</span><span class="n">ifndef</span> <span class="b">Py_LIMITED_API</span>
<a name="71" /><span class="True">      71:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfRk9SQ0VfRE9VQkxFXzA_"><span class="b">Py_FORCE_DOUBLE</span></a>
<a name="72" /><span class="False">      72:</span> <span class="f">#</span>  <span class="n">ifdef</span> <span class="b">X87_DOUBLE_ROUNDING</span>
<a name="73" /><span class="False">      73:</span> <a href="macros_ref.html#_UHlBUElfRlVOQ18w"><span class="b">PyAPI_FUNC</span></a><span class="f">(</span><span class="m">double</span><span class="f">)</span> <span class="b">_Py_force_double</span><span class="f">(</span><span class="m">double</span><span class="f">)</span><span class="f">;</span>
<a name="74" /><span class="False">      74:</span> <span class="f">#</span>    <span class="n">define</span> <a href="macros_noref.html#_UHlfRk9SQ0VfRE9VQkxFXzA_"><span class="b">Py_FORCE_DOUBLE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="b">_Py_force_double</span><span class="f">(</span><span class="b">X</span><span class="f">)</span><span class="f">)</span>
<a name="75" /><span class="True">      75:</span> <span class="f">#</span>  <span class="n">else</span>
<a name="76" /><span class="True">      76:</span> <span class="f">#</span>    <span class="n">define</span> <a href="macros_noref.html#_UHlfRk9SQ0VfRE9VQkxFXzA_"><span class="b">Py_FORCE_DOUBLE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="77" /><span class="True">      77:</span> <span class="f">#</span>  <span class="n">endif</span>
<a name="78" /><span class="True">      78:</span> <span class="f">#</span><span class="n">endif</span>
<a name="79" /><span class="True">      79:</span> <span class="f">#</span><span class="n">endif</span>
<a name="80" /><span class="True">      80:</span> 
<a name="81" /><span class="True">      81:</span> <span class="f">#</span><span class="n">ifndef</span> <span class="b">Py_LIMITED_API</span>
<a name="82" /><span class="True">      82:</span> <span class="f">#</span><span class="n">ifdef</span> <a href="macros_ref.html#_SEFWRV9HQ0NfQVNNX0ZPUl9YODdfMA__"><span class="b">HAVE_GCC_ASM_FOR_X87</span></a>
<a name="83" /><span class="True">      83:</span> <a href="macros_ref.html#_UHlBUElfRlVOQ18w"><span class="b">PyAPI_FUNC</span></a><span class="f">(</span><span class="m">unsigned</span> <span class="m">short</span><span class="f">)</span> <span class="b">_Py_get_387controlword</span><span class="f">(</span><span class="m">void</span><span class="f">)</span><span class="f">;</span>
<a name="84" /><span class="True">      84:</span> <a href="macros_ref.html#_UHlBUElfRlVOQ18w"><span class="b">PyAPI_FUNC</span></a><span class="f">(</span><span class="m">void</span><span class="f">)</span> <span class="b">_Py_set_387controlword</span><span class="f">(</span><span class="m">unsigned</span> <span class="m">short</span><span class="f">)</span><span class="f">;</span>
<a name="85" /><span class="True">      85:</span> <span class="f">#</span><span class="n">endif</span>
<a name="86" /><span class="True">      86:</span> <span class="f">#</span><span class="n">endif</span>
<a name="87" /><span class="True">      87:</span> 
<a name="88" /><span class="True">      88:</span> <span class="k">/* Py_IS_NAN(X)</span>
<a name="89" /><span class="True">      89:</span> <span class="k"> * Return 1 if float or double arg is a NaN, else 0.</span>
<a name="90" /><span class="True">      90:</span> <span class="k"> * Caution:</span>
<a name="91" /><span class="True">      91:</span> <span class="k"> *     X is evaluated more than once.</span>
<a name="92" /><span class="True">      92:</span> <span class="k"> *     This may not work on all platforms.  Each platform has *some*</span>
<a name="93" /><span class="True">      93:</span> <span class="k"> *     way to spell this, though -- override in pyconfig.h if you have</span>
<a name="94" /><span class="True">      94:</span> <span class="k"> *     a platform where it doesn&apos;t work.</span>
<a name="95" /><span class="True">      95:</span> <span class="k"> * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan</span>
<a name="96" /><span class="True">      96:</span> <span class="k"> */</span>
<a name="97" /><span class="True">      97:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfSVNfTkFOXzA_"><span class="b">Py_IS_NAN</span></a>
<a name="98" /><span class="True">      98:</span> <span class="f">#</span><span class="n">if</span> <span class="b">defined</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTTkFOXzA_"><span class="b">HAVE_DECL_ISNAN</span></a> <span class="f">&amp;&amp;</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTTkFOXzA_"><span class="b">HAVE_DECL_ISNAN</span></a> <span class="f">==</span> <span class="c">1</span>
<a name="99" /><span class="True">      99:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfTkFOXzA_"><span class="b">Py_IS_NAN</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <a href="macros_noref.html#_aXNuYW5fMA__"><span class="b">isnan</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="100" /><span class="False">     100:</span> <span class="f">#</span><span class="n">else</span>
<a name="101" /><span class="False">     101:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfTkFOXzA_"><span class="b">Py_IS_NAN</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">!=</span> <span class="f">(</span><span class="b">X</span><span class="f">)</span><span class="f">)</span>
<a name="102" /><span class="True">     102:</span> <span class="f">#</span><span class="n">endif</span>
<a name="103" /><span class="True">     103:</span> <span class="f">#</span><span class="n">endif</span>
<a name="104" /><span class="True">     104:</span> 
<a name="105" /><span class="True">     105:</span> <span class="k">/* Py_IS_INFINITY(X)</span>
<a name="106" /><span class="True">     106:</span> <span class="k"> * Return 1 if float or double arg is an infinity, else 0.</span>
<a name="107" /><span class="True">     107:</span> <span class="k"> * Caution:</span>
<a name="108" /><span class="True">     108:</span> <span class="k"> *    X is evaluated more than once.</span>
<a name="109" /><span class="True">     109:</span> <span class="k"> *    This implementation may set the underflow flag if |X| is very small;</span>
<a name="110" /><span class="True">     110:</span> <span class="k"> *    it really can&apos;t be implemented correctly (&amp; easily) before C99.</span>
<a name="111" /><span class="True">     111:</span> <span class="k"> *    Override in pyconfig.h if you have a better spelling on your platform.</span>
<a name="112" /><span class="True">     112:</span> <span class="k"> *  Py_FORCE_DOUBLE is used to avoid getting false negatives from a</span>
<a name="113" /><span class="True">     113:</span> <span class="k"> *    non-infinite value v sitting in an 80-bit x87 register such that</span>
<a name="114" /><span class="True">     114:</span> <span class="k"> *    v becomes infinite when spilled from the register to 64-bit memory.</span>
<a name="115" /><span class="True">     115:</span> <span class="k"> * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf</span>
<a name="116" /><span class="True">     116:</span> <span class="k"> */</span>
<a name="117" /><span class="True">     117:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfSVNfSU5GSU5JVFlfMA__"><span class="b">Py_IS_INFINITY</span></a>
<a name="118" /><span class="True">     118:</span> <span class="f">#</span>  <span class="n">if</span> <span class="b">defined</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTSU5GXzA_"><span class="b">HAVE_DECL_ISINF</span></a> <span class="f">&amp;&amp;</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTSU5GXzA_"><span class="b">HAVE_DECL_ISINF</span></a> <span class="f">==</span> <span class="c">1</span>
<a name="119" /><span class="True">     119:</span> <span class="f">#</span>    <span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfSU5GSU5JVFlfMA__"><span class="b">Py_IS_INFINITY</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <a href="macros_noref.html#_aXNpbmZfMA__"><span class="b">isinf</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="120" /><span class="False">     120:</span> <span class="f">#</span>  <span class="n">else</span>
<a name="121" /><span class="False">     121:</span> <span class="f">#</span>    <span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfSU5GSU5JVFlfMA__"><span class="b">Py_IS_INFINITY</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">&amp;&amp;</span>                                   \
<a name="122" /><span class="False">     122:</span>                                <span class="f">(</span><a href="macros_noref.html#_UHlfRk9SQ0VfRE9VQkxFXzA_"><span class="b">Py_FORCE_DOUBLE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span><span class="f">*</span><span class="c">0.5</span> <span class="f">==</span> <a href="macros_noref.html#_UHlfRk9SQ0VfRE9VQkxFXzA_"><span class="b">Py_FORCE_DOUBLE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span><span class="f">)</span><span class="f">)</span>
<a name="123" /><span class="True">     123:</span> <span class="f">#</span>  <span class="n">endif</span>
<a name="124" /><span class="True">     124:</span> <span class="f">#</span><span class="n">endif</span>
<a name="125" /><span class="True">     125:</span> 
<a name="126" /><span class="True">     126:</span> <span class="k">/* Py_IS_FINITE(X)</span>
<a name="127" /><span class="True">     127:</span> <span class="k"> * Return 1 if float or double arg is neither infinite nor NAN, else 0.</span>
<a name="128" /><span class="True">     128:</span> <span class="k"> * Some compilers (e.g. VisualStudio) have intrisics for this, so a special</span>
<a name="129" /><span class="True">     129:</span> <span class="k"> * macro for this particular test is useful</span>
<a name="130" /><span class="True">     130:</span> <span class="k"> * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite</span>
<a name="131" /><span class="True">     131:</span> <span class="k"> */</span>
<a name="132" /><span class="True">     132:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfSVNfRklOSVRFXzA_"><span class="b">Py_IS_FINITE</span></a>
<a name="133" /><span class="True">     133:</span> <span class="f">#</span><span class="n">if</span> <span class="b">defined</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTRklOSVRFXzA_"><span class="b">HAVE_DECL_ISFINITE</span></a> <span class="f">&amp;&amp;</span> <a href="macros_ref.html#_SEFWRV9ERUNMX0lTRklOSVRFXzA_"><span class="b">HAVE_DECL_ISFINITE</span></a> <span class="f">==</span> <span class="c">1</span>
<a name="134" /><span class="True">     134:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfRklOSVRFXzA_"><span class="b">Py_IS_FINITE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <a href="macros_noref.html#_aXNmaW5pdGVfMA__"><span class="b">isfinite</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="135" /><span class="False">     135:</span> <span class="f">#</span><span class="n">elif</span> <span class="b">defined</span> <a href="macros_noref.html#_SEFWRV9GSU5JVEVfMA__"><span class="b">HAVE_FINITE</span></a>
<a name="136" /><span class="False">     136:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfRklOSVRFXzA_"><span class="b">Py_IS_FINITE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="b">finite</span><span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="137" /><span class="False">     137:</span> <span class="f">#</span><span class="n">else</span>
<a name="138" /><span class="False">     138:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSVNfRklOSVRFXzA_"><span class="b">Py_IS_FINITE</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="f">!</span><a href="macros_noref.html#_UHlfSVNfSU5GSU5JVFlfMA__"><span class="b">Py_IS_INFINITY</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">&amp;&amp;</span> <span class="f">!</span><a href="macros_noref.html#_UHlfSVNfTkFOXzA_"><span class="b">Py_IS_NAN</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span><span class="f">)</span>
<a name="139" /><span class="True">     139:</span> <span class="f">#</span><span class="n">endif</span>
<a name="140" /><span class="True">     140:</span> <span class="f">#</span><span class="n">endif</span>
<a name="141" /><span class="True">     141:</span> 
<a name="142" /><span class="True">     142:</span> <span class="k">/* HUGE_VAL is supposed to expand to a positive double infinity.  Python</span>
<a name="143" /><span class="True">     143:</span> <span class="k"> * uses Py_HUGE_VAL instead because some platforms are broken in this</span>
<a name="144" /><span class="True">     144:</span> <span class="k"> * respect.  We used to embed code in pyport.h to try to worm around that,</span>
<a name="145" /><span class="True">     145:</span> <span class="k"> * but different platforms are broken in conflicting ways.  If you&apos;re on</span>
<a name="146" /><span class="True">     146:</span> <span class="k"> * a platform where HUGE_VAL is defined incorrectly, fiddle your Python</span>
<a name="147" /><span class="True">     147:</span> <span class="k"> * config to #define Py_HUGE_VAL to something that works on your platform.</span>
<a name="148" /><span class="True">     148:</span> <span class="k"> */</span>
<a name="149" /><span class="True">     149:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="macros_noref.html#_UHlfSFVHRV9WQUxfMA__"><span class="b">Py_HUGE_VAL</span></a>
<a name="150" /><span class="True">     150:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfSFVHRV9WQUxfMA__"><span class="b">Py_HUGE_VAL</span></a> <a href="macros_noref.html#_SFVHRV9WQUxfMA__"><span class="b">HUGE_VAL</span></a>
<a name="151" /><span class="True">     151:</span> <span class="f">#</span><span class="n">endif</span>
<a name="152" /><span class="True">     152:</span> 
<a name="153" /><span class="True">     153:</span> <span class="k">/* Py_NAN</span>
<a name="154" /><span class="True">     154:</span> <span class="k"> * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or</span>
<a name="155" /><span class="True">     155:</span> <span class="k"> * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform</span>
<a name="156" /><span class="True">     156:</span> <span class="k"> * doesn&apos;t support NaNs.</span>
<a name="157" /><span class="True">     157:</span> <span class="k"> */</span>
<a name="158" /><span class="True">     158:</span> <span class="f">#</span><span class="n">if</span> <span class="f">!</span><span class="b">defined</span><span class="f">(</span><a href="macros_ref.html#_UHlfTkFOXzA_"><span class="b">Py_NAN</span></a><span class="f">)</span> <span class="f">&amp;&amp;</span> <span class="f">!</span><span class="b">defined</span><span class="f">(</span><span class="b">Py_NO_NAN</span><span class="f">)</span>
<a name="159" /><span class="True">     159:</span> <span class="f">#</span><span class="n">if</span> <span class="f">!</span><span class="b">defined</span><span class="f">(</span><span class="b">__INTEL_COMPILER</span><span class="f">)</span>
<a name="160" /><span class="True">     160:</span>     <span class="f">#</span><span class="n">define</span> <a href="macros_ref.html#_UHlfTkFOXzA_"><span class="b">Py_NAN</span></a> <span class="f">(</span><a href="macros_noref.html#_UHlfSFVHRV9WQUxfMA__"><span class="b">Py_HUGE_VAL</span></a> <span class="f">*</span> <span class="c">0.</span><span class="f">)</span>
<a name="161" /><span class="False">     161:</span> <span class="f">#</span><span class="n">else</span> <span class="k">/* __INTEL_COMPILER */</span>
<a name="162" /><span class="False">     162:</span>     <span class="f">#</span><span class="n">if</span> <span class="b">defined</span><span class="f">(</span><span class="b">ICC_NAN_STRICT</span><span class="f">)</span>
<a name="163" /><span class="False">     163:</span>         <span class="f">#</span><span class="n">pragma</span> <span class="b">float_control</span><span class="f">(</span><span class="b">push</span><span class="f">)</span>
<a name="164" /><span class="False">     164:</span>         <span class="f">#</span><span class="n">pragma</span> <span class="b">float_control</span><span class="f">(</span><span class="b">precise</span><span class="f">,</span> <span class="b">on</span><span class="f">)</span>
<a name="165" /><span class="False">     165:</span>         <span class="f">#</span><span class="n">pragma</span> <span class="b">float_control</span><span class="f">(</span><span class="b">except</span><span class="f">,</span>  <span class="b">on</span><span class="f">)</span>
<a name="166" /><span class="False">     166:</span>         <span class="f">#</span><span class="n">if</span> <span class="b">defined</span><span class="f">(</span><span class="b">_MSC_VER</span><span class="f">)</span>
<a name="167" /><span class="False">     167:</span>             <span class="b">__declspec</span><span class="f">(</span><span class="b">noinline</span><span class="f">)</span>
<a name="168" /><span class="False">     168:</span>         <span class="f">#</span><span class="n">else</span> <span class="k">/* Linux */</span>
<a name="169" /><span class="False">     169:</span>             <span class="b">__attribute__</span><span class="f">(</span><span class="f">(</span><span class="b">noinline</span><span class="f">)</span><span class="f">)</span>
<a name="170" /><span class="False">     170:</span>         <span class="f">#</span><span class="n">endif</span> <span class="k">/* _MSC_VER */</span>
<a name="171" /><span class="False">     171:</span>         <span class="m">static</span> <span class="m">double</span> <span class="b">__icc_nan</span><span class="f">(</span><span class="f">)</span>
<a name="172" /><span class="False">     172:</span>         <span class="f">{</span>
<a name="173" /><span class="False">     173:</span>             <span class="m">return</span> <span class="b">sqrt</span><span class="f">(</span><span class="f">-</span><span class="c">1.0</span><span class="f">)</span><span class="f">;</span>
<a name="174" /><span class="False">     174:</span>         <span class="f">}</span>
<a name="175" /><span class="False">     175:</span>         <span class="f">#</span><span class="n">pragma</span> <span class="b">float_control</span> <span class="f">(</span><span class="b">pop</span><span class="f">)</span>
<a name="176" /><span class="False">     176:</span>         <span class="f">#</span><span class="n">define</span> <a href="macros_ref.html#_UHlfTkFOXzA_"><span class="b">Py_NAN</span></a> <span class="b">__icc_nan</span><span class="f">(</span><span class="f">)</span>
<a name="177" /><span class="False">     177:</span>     <span class="f">#</span><span class="n">else</span> <span class="k">/* ICC_NAN_RELAXED as default for Intel Compiler */</span>
<a name="178" /><span class="False">     178:</span>         <span class="m">static</span> <span class="m">const</span> <span class="m">union</span> <span class="f">{</span> <span class="m">unsigned</span> <span class="m">char</span> <span class="b">buf</span><span class="f">[</span><span class="c">8</span><span class="f">]</span><span class="f">;</span> <span class="m">double</span> <span class="b">__icc_nan</span><span class="f">;</span> <span class="f">}</span> <span class="b">__nan_store</span> <span class="f">=</span> <span class="f">{</span><span class="c">0</span><span class="f">,</span><span class="c">0</span><span class="f">,</span><span class="c">0</span><span class="f">,</span><span class="c">0</span><span class="f">,</span><span class="c">0</span><span class="f">,</span><span class="c">0</span><span class="f">,</span><span class="c">0xf8</span><span class="f">,</span><span class="c">0x7f</span><span class="f">}</span><span class="f">;</span>
<a name="179" /><span class="False">     179:</span>         <span class="f">#</span><span class="n">define</span> <a href="macros_ref.html#_UHlfTkFOXzA_"><span class="b">Py_NAN</span></a> <span class="f">(</span><span class="b">__nan_store</span><span class="f">.</span><span class="b">__icc_nan</span><span class="f">)</span>
<a name="180" /><span class="False">     180:</span>     <span class="f">#</span><span class="n">endif</span> <span class="k">/* ICC_NAN_STRICT */</span>
<a name="181" /><span class="True">     181:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* __INTEL_COMPILER */</span>
<a name="182" /><span class="True">     182:</span> <span class="f">#</span><span class="n">endif</span>
<a name="183" /><span class="True">     183:</span> 
<a name="184" /><span class="True">     184:</span> <span class="k">/* Py_OVERFLOWED(X)</span>
<a name="185" /><span class="True">     185:</span> <span class="k"> * Return 1 iff a libm function overflowed.  Set errno to 0 before calling</span>
<a name="186" /><span class="True">     186:</span> <span class="k"> * a libm function, and invoke this macro after, passing the function</span>
<a name="187" /><span class="True">     187:</span> <span class="k"> * result.</span>
<a name="188" /><span class="True">     188:</span> <span class="k"> * Caution:</span>
<a name="189" /><span class="True">     189:</span> <span class="k"> *    This isn&apos;t reliable.  C99 no longer requires libm to set errno under</span>
<a name="190" /><span class="True">     190:</span> <span class="k"> *      any exceptional condition, but does require +- HUGE_VAL return</span>
<a name="191" /><span class="True">     191:</span> <span class="k"> *      values on overflow.  A 754 box *probably* maps HUGE_VAL to a</span>
<a name="192" /><span class="True">     192:</span> <span class="k"> *      double infinity, and we&apos;re cool if that&apos;s so, unless the input</span>
<a name="193" /><span class="True">     193:</span> <span class="k"> *      was an infinity and an infinity is the expected result.  A C89</span>
<a name="194" /><span class="True">     194:</span> <span class="k"> *      system sets errno to ERANGE, so we check for that too.  We&apos;re</span>
<a name="195" /><span class="True">     195:</span> <span class="k"> *      out of luck if a C99 754 box doesn&apos;t map HUGE_VAL to +Inf, or</span>
<a name="196" /><span class="True">     196:</span> <span class="k"> *      if the returned result is a NaN, or if a C89 box returns HUGE_VAL</span>
<a name="197" /><span class="True">     197:</span> <span class="k"> *      in non-overflow cases.</span>
<a name="198" /><span class="True">     198:</span> <span class="k"> *    X is evaluated more than once.</span>
<a name="199" /><span class="True">     199:</span> <span class="k"> * Some platforms have better way to spell this, so expect some #ifdef&apos;ery.</span>
<a name="200" /><span class="True">     200:</span> <span class="k"> *</span>
<a name="201" /><span class="True">     201:</span> <span class="k"> * OpenBSD uses &apos;isinf()&apos; because a compiler bug on that platform causes</span>
<a name="202" /><span class="True">     202:</span> <span class="k"> * the longer macro version to be mis-compiled. This isn&apos;t optimal, and</span>
<a name="203" /><span class="True">     203:</span> <span class="k"> * should be removed once a newer compiler is available on that platform.</span>
<a name="204" /><span class="True">     204:</span> <span class="k"> * The system that had the failure was running OpenBSD 3.2 on Intel, with</span>
<a name="205" /><span class="True">     205:</span> <span class="k"> * gcc 2.95.3.</span>
<a name="206" /><span class="True">     206:</span> <span class="k"> *</span>
<a name="207" /><span class="True">     207:</span> <span class="k"> * According to Tim&apos;s checkin, the FreeBSD systems use isinf() to work</span>
<a name="208" /><span class="True">     208:</span> <span class="k"> * around a FPE bug on that platform.</span>
<a name="209" /><span class="True">     209:</span> <span class="k"> */</span>
<a name="210" /><span class="False">     210:</span> <span class="f">#</span><span class="n">if</span> <span class="b">defined</span><span class="f">(</span><span class="b">__FreeBSD__</span><span class="f">)</span> <span class="f">||</span> <span class="b">defined</span><span class="f">(</span><span class="b">__OpenBSD__</span><span class="f">)</span>
<a name="211" /><span class="False">     211:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfT1ZFUkZMT1dFRF8w"><span class="b">Py_OVERFLOWED</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <a href="macros_noref.html#_aXNpbmZfMA__"><span class="b">isinf</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span>
<a name="212" /><span class="True">     212:</span> <span class="f">#</span><span class="n">else</span>
<a name="213" /><span class="True">     213:</span> <span class="f">#</span><span class="n">define</span> <a href="macros_noref.html#_UHlfT1ZFUkZMT1dFRF8w"><span class="b">Py_OVERFLOWED</span></a><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">(</span><span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">!=</span> <span class="c">0.0</span> <span class="f">&amp;&amp;</span> <span class="f">(</span><a href="macros_noref.html#_ZXJybm9fMA__"><span class="b">errno</span></a> <span class="f">==</span> <a href="macros_noref.html#_RVJBTkdFXzA_"><span class="b">ERANGE</span></a> <span class="f">||</span>    \
<a name="214" /><span class="True">     214:</span>                      <span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">==</span> <a href="macros_noref.html#_UHlfSFVHRV9WQUxfMA__"><span class="b">Py_HUGE_VAL</span></a> <span class="f">||</span> \
<a name="215" /><span class="True">     215:</span>                      <span class="f">(</span><span class="b">X</span><span class="f">)</span> <span class="f">==</span> <span class="f">-</span><a href="macros_noref.html#_UHlfSFVHRV9WQUxfMA__"><span class="b">Py_HUGE_VAL</span></a><span class="f">)</span><span class="f">)</span>
<a name="216" /><span class="True">     216:</span> <span class="f">#</span><span class="n">endif</span>
<a name="217" /><span class="True">     217:</span> 
<a name="218" /><span class="True">     218:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* Py_PYMATH_H */</span>
<a name="219" /><span class="True">     219:</span> </pre>
  </body>
</html>
